/**
 * <copyright> </copyright>
 * 
 * $Id$
 */
package org.dengues.model.database.impl;

import java.util.HashMap;

import org.dengues.model.database.AbstractDBObject;
import org.dengues.model.database.DatabaseFactory;
import org.dengues.model.database.DatabasePackage;
import org.dengues.model.database.EMFDataType;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc --> An implementation of the model object '<em><b>Abstract DB Object</b></em>'. <!--
 * end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.dengues.model.database.impl.AbstractDBObjectImpl#getProperties <em>Properties</em>}</li>
 *   <li>{@link org.dengues.model.database.impl.AbstractDBObjectImpl#getName <em>Name</em>}</li>
 *   <li>{@link org.dengues.model.database.impl.AbstractDBObjectImpl#getEmfType <em>Emf Type</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class AbstractDBObjectImpl extends EObjectImpl implements AbstractDBObject {

    /**
     * The default value of the '{@link #getProperties() <em>Properties</em>}' attribute. <!-- begin-user-doc --> <!--
     * end-user-doc -->
     * 
     * @see #getProperties()
     * @ordered
     */
    protected static final HashMap PROPERTIES_EDEFAULT = (HashMap) DatabaseFactory.eINSTANCE.createFromString(
            DatabasePackage.eINSTANCE.getPropMap(), "");

    /**
     * The cached value of the '{@link #getProperties() <em>Properties</em>}' attribute. <!-- begin-user-doc --> <!--
     * end-user-doc -->
     * 
     * @see #getProperties()
     * @ordered
     */
    protected HashMap properties = (HashMap) PROPERTIES_EDEFAULT.clone();

    /**
     * The default value of the '{@link #getName() <em>Name</em>}' attribute.
     * <!-- begin-user-doc --> <!--
     * end-user-doc -->
     * @see #getName()
     * @generated
     * @ordered
     */
    protected static final String NAME_EDEFAULT = null;

    /**
     * The cached value of the '{@link #getName() <em>Name</em>}' attribute. <!-- begin-user-doc --> <!-- end-user-doc
     * -->
     * 
     * @see #getName()
     * @generated
     * @ordered
     */
    protected String name = NAME_EDEFAULT;

    /**
     * The default value of the '{@link #getEmfType() <em>Emf Type</em>}' attribute.
     * <!-- begin-user-doc --> <!--
     * end-user-doc -->
     * @see #getEmfType()
     * @generated
     * @ordered
     */
    protected static final EMFDataType EMF_TYPE_EDEFAULT = EMFDataType.DATABASE_LITERAL;

    /**
     * The cached value of the '{@link #getEmfType() <em>Emf Type</em>}' attribute.
     * <!-- begin-user-doc --> <!--
     * end-user-doc -->
     * @see #getEmfType()
     * @generated
     * @ordered
     */
    protected EMFDataType emfType = EMF_TYPE_EDEFAULT;

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * @generated
     */
    protected AbstractDBObjectImpl() {
        super();
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * @generated
     */
    @Override
    protected EClass eStaticClass() {
        return DatabasePackage.Literals.ABSTRACT_DB_OBJECT;
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * @generated
     */
    public HashMap getProperties() {
        return properties;
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * @generated
     */
    public void setProperties(HashMap newProperties) {
        HashMap oldProperties = properties;
        properties = newProperties;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, DatabasePackage.ABSTRACT_DB_OBJECT__PROPERTIES, oldProperties, properties));
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * @generated
     */
    public String getName() {
        return name;
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * @generated
     */
    public void setName(String newName) {
        String oldName = name;
        name = newName;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, DatabasePackage.ABSTRACT_DB_OBJECT__NAME, oldName, name));
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * @generated
     */
    public EMFDataType getEmfType() {
        return emfType;
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * @generated
     */
    public void setEmfType(EMFDataType newEmfType) {
        EMFDataType oldEmfType = emfType;
        emfType = newEmfType == null ? EMF_TYPE_EDEFAULT : newEmfType;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, DatabasePackage.ABSTRACT_DB_OBJECT__EMF_TYPE, oldEmfType, emfType));
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * @generated
     */
    @Override
    public Object eGet(int featureID, boolean resolve, boolean coreType) {
        switch (featureID) {
            case DatabasePackage.ABSTRACT_DB_OBJECT__PROPERTIES:
                return getProperties();
            case DatabasePackage.ABSTRACT_DB_OBJECT__NAME:
                return getName();
            case DatabasePackage.ABSTRACT_DB_OBJECT__EMF_TYPE:
                return getEmfType();
        }
        return super.eGet(featureID, resolve, coreType);
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * @generated
     */
    @Override
    public void eSet(int featureID, Object newValue) {
        switch (featureID) {
            case DatabasePackage.ABSTRACT_DB_OBJECT__PROPERTIES:
                setProperties((HashMap)newValue);
                return;
            case DatabasePackage.ABSTRACT_DB_OBJECT__NAME:
                setName((String)newValue);
                return;
            case DatabasePackage.ABSTRACT_DB_OBJECT__EMF_TYPE:
                setEmfType((EMFDataType)newValue);
                return;
        }
        super.eSet(featureID, newValue);
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * @generated
     */
    @Override
    public void eUnset(int featureID) {
        switch (featureID) {
            case DatabasePackage.ABSTRACT_DB_OBJECT__PROPERTIES:
                setProperties(PROPERTIES_EDEFAULT);
                return;
            case DatabasePackage.ABSTRACT_DB_OBJECT__NAME:
                setName(NAME_EDEFAULT);
                return;
            case DatabasePackage.ABSTRACT_DB_OBJECT__EMF_TYPE:
                setEmfType(EMF_TYPE_EDEFAULT);
                return;
        }
        super.eUnset(featureID);
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * @generated
     */
    @Override
    public boolean eIsSet(int featureID) {
        switch (featureID) {
            case DatabasePackage.ABSTRACT_DB_OBJECT__PROPERTIES:
                return PROPERTIES_EDEFAULT == null ? properties != null : !PROPERTIES_EDEFAULT.equals(properties);
            case DatabasePackage.ABSTRACT_DB_OBJECT__NAME:
                return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
            case DatabasePackage.ABSTRACT_DB_OBJECT__EMF_TYPE:
                return emfType != EMF_TYPE_EDEFAULT;
        }
        return super.eIsSet(featureID);
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * @generated
     */
    @Override
    public String toString() {
        if (eIsProxy()) return super.toString();

        StringBuffer result = new StringBuffer(super.toString());
        result.append(" (properties: ");
        result.append(properties);
        result.append(", name: ");
        result.append(name);
        result.append(", emfType: ");
        result.append(emfType);
        result.append(')');
        return result.toString();
    }

} // AbstractDBObjectImpl
